#!/bin/bash

# JAR文件的路径
JAR_PATH="/data/app/stone-boot/stone-boot.jar"
# JAR文件的名称（不含.jar后缀）
JAR_NAME="stone-boot"

# 日志文件的路径
LOG_FILE="/data/app/stone-boot/log/stone-boot.log"

# 检查JAR文件是否存在
if [ ! -f "$JAR_PATH" ]; then
    echo "JAR file does not exist: $JAR_PATH"
    exit 1
fi

# 启动JAR服务，并将其输出重定向到日志文件，同时在后台运行
nohup java -jar $JAR_PATH > "$LOG_FILE" 2>&1 &

# 检查服务是否启动成功
if [ $? -eq 0 ]; then
    echo "$JAR_NAME has been started successfully and is running in the background."
else
    echo "Failed to start $JAR_NAME."
    exit 1
fi